renaming things to make clearer; abstracting more variables