Refactoring to make use of inheritance