clean up and refactoring