thorough refactoring