Update build script, add version check