fixed a bug where query was looking for db instead of database