updated version of triangle counting