Refactored code for rendering leaderboard templates.