improve upgrade script