Started refactoring
Merge with new code
Refactored