improve upgarde script to allow output
fix extra brackets around expressions