Refactored common str concat into a function
Added support for the simple query api.