Refactored function to update the score on its own