Make more solutions tail recursive