implemented dynamic queries

#1