Refactored scoring.php