small refactor, a bit neater