implemented by Daniel C. Liem

Code Credit to theSpite, Jaume Elias