fixed bugs, now completely working