fixed logic & comments related to $KEEP_NEARBY_QUERY