refactor to eventually support breaking up into tasks/supporting stdin/etc