fixed error using factory