trying to fix recursion vs closure