fix loop break bug