Fixing duplicate edges bug