Handle err when finishing querying