Added infer option to query method