added query functionality in gibbs_output