refactor out mode-applying into a separate method