Added tail call optimization