renamed some variables, and added comments