trying to fix recursion bug