more robust build script