final refactoring complete