Pull calculation functions out to controller scope