fixed some bugs caused by my changes