implemented triangle counting