Logic for ranking is done.