used a central function for building the query