mostly refactoring