Modify getinstance, and handle the query that gets passed to listinstances