Added algorithm to deal with problem vertices