fixes some bugs, now it's perfect