finished rank() method