Added query functionality