factor out functions from build.ls