small refactoring and simplification