refactored code to use a factorial extension method