improve build script

Using `global` here doesn't  is nonsense.