refactoring a lot