fixed some bugs, still not working right