fixed error in ranking algorithm