initial version, based on Gareth's great blog posts on workflows