Move a bit of logic out of the view