put script diff into function