added comments and fixed variable names