Fixed the bugs