updated score function