fix some possible bugs