small refactoring and comments