Moved some calculations from the view to the model