minor clean up and refactoring