added use of database in query selector (to be able to support using multiple database in at the same time)
updated based on the latest version of the core library