lot of refactoring