Dynamic Allocation

Dynamic allocation
Cleaner query modification method