trying to count nearest neighbours