Completed score() function.