added score tracking to the merge function