finally refactored 2d array adjacency reading code