Refactored scoreboard code