calculate ranking