Rank_rate beautify code