major refactor