line 4-66 functions to rank, keep track, and mutate