fix some crash cases