fixed some bugs (broken version)