updated with nearest neighbor marking