small refactor

Reduced some code duplication