added constraints in Query