fixed some bugs in here