Update build code

revert if it is wrong but the originals don't seem to work.