Updated order of variable declaration to fix logic error in gamma and fact functions