replaced some variables to make the code clearer