removed recursion 

removed recursion to make it a bit faster.