Minor refactor to DRY up code.