move anonymous function closure into build script