Reworded some variables and put comments so it's easier to follow.