added queryIndex method, added constructor with different parameters