Refact build script