Added a correctEdges function.