refactor namespaces and from in queries. DRY