rewritten build script