small refactoring of code