Fixed a bug with neighbor checking in the previous version.