Tidy the controller override code into a mixin for easier reuse