implemented basic tail call optimizations