Added tail calls optimization