small refactoring, had duplicated code