refactoring

cleanup and refactoring