major refactoring part 2