adapting code for non-db option

streamlining some code first