rename a couple of variables and add some more comments