factorial was corrected using tail recursion