refactored names of some variables for clarity