Added the query option and use query in case it is present