Added a rank function