fixed a sign in compute_error_index