Changed iteration over neighbors to map.