refactored factorial - fixed frontend