get rid of recursion