Rewrote scoring_function