fix crash bugs