factored out basic workflow