Adding code for Factory Method Pattern