added comments and removed uneeded variables