refactoring

refactoring and cleanup