clean-up and refactoring