recursion oprimization verified with tailrec