improve data validation for Query