removed most of the bugs, works