fixed some bugs in the class