optimizing link counting