move score function to global file