Fixed error calculation