script to build prepare.q