Convert reverse to proper tail recursive form