refactoring & cleanup