Fixed edgeExists method