Added a method to return the topology and fixed a out of bounds error