fix parser error message; change tails to use fold-right