minor change to rank function