autoQuery implementation.