function composition now uses recursion instead of linked lists