fix so registering an squery generates a unique handle and returns it