renamed some variables to make their use clearer