bug fixed: counting edges