composing functions, tail recursion