refactoring/optimize