fixed some possible bugs