I'm sure there's a more efficient way to do this with ranks but I don't know it. So any help would be greatly appreciated.