fixed some of the bugs