small refactor to facilitate easier testing