Finished and tested the score function