completed final refactoring