Added comments for each line of code and fixed variables to make more sense.