Fixed fatal error in upgrade script