refactor get_score function