some small refactorings to make code more concise