minor refactoring
query building refactoring, updated demo pages
refactor