got things working, fixed double definition of factorial