Edited some variable names to make the code more clear