Updated factorial method