changed and fixed some bugs