Fixed bugs, Modified codes for PR