added adjacency detection