A bit of refactoring

Twelve lines of code less and only two more