update neighbor detect algorithm