fix incorrect if for error code