Added more intelligent neighbors function