made final refactoring