That probably is the best way to do it without any built in functions :P