Move some model code to the controller