Moves logic outside the view to the model