Move calculations from view into model