fixed some crash bugs