fixed some bugs, now it runs