Added dynamic query creator