fix bugs
Changed the code