small refactoring and cleanup