fix bug which may cause crash