tried to fix some bugs