Fixed a dumb in rank()