Fixed bug with tail calls