Fixed elseif bug in proc QueryRequest