Added query code