initial script, now getting complex enough it needs version control