document and clean build function