fixed integral error calculation