switch on query success