decrease number of queries in filtering