Added recursive tail call optimisation and fixed parsing issue