added function for rank selection