bugfixes to query and database name