WIP
merged and refactoring