avoiding use of arrays in query