Simplify recursion to fns