fixed most of the bugs