Implementation of Factory Method design pattern