fixup! optimize queries using the distance function