update nearby logic to eliminate array usage