built the script (first pass)