Added support for dynamic query construction