Fixed problem with empty queries