Refactoring to different classes to remove switch