working score function