getting rid of a recursion bug