Implementing the factory method pattern