added some more comments and deleted some unnecessary code