finished 1st refactoring