improvements in upgrade script