added rank function