removed unnecessary passing of variables and added comments