Finished basic algorithm for leaderboard rankings