fixed some bugs in last commit