Refactor factory_method.go