fixed some bugs, I hope