Changed formula for queries