finish refactoring with inheritance