fix some neighboring edges conditions to avoid repeats