started refactoring
first round of refactoring over