trying to improve rebuild script