tweaked upgrade script