first implementation of similarity query