code refactoring & cleanup