major refactoring part 1
major refactoring part 2