Refactored to use factory class instead factory method