added flexible query capability