added query functionality