giant refactoring part 1