Addded validation to query inputs.