added comments, removed unnecessary lines of code