refactoring to minimise code smells (detected with reek)