small refactoring of the code