Change to_query method