made a few changes to code