Attempt to better implement the factory pattern