Made some improvements to the query methods