Refactoring the classes - separating the common and specific logic