renamed some variables for clear understanding