worked on factorial functions