more cleanup, move the scoring to a function