some of the bugs fixed