Optimized build script
Add checks to build script