Changed recursion to loop

It appears to work, sort of.