move scoring to function