Adding @tailrec annotation