did some major refactoring