refactored a lot
refactoring finished
merged