slight tidy of gavin_function