added pin counting functionality. Pin counting has passed tests.