major refactoring under the hood