renamed some variables to make it easier to understand
same