fixed proximity query, ready to merge