Changed global error calculation