Fix factored code