fix bugs in ranking