modifications to use more meaningful variable names, addition of comments