major refactor begins