create util file and factored out some code from build script