more clean up and refactoring