first major refactor