fix bug with empty queries