Code refactor to customize implementation in factory