Factoring out common controller code