Fix error calculation