Pulled out a build function.