shitload of refactoring