Fixed an error in pin counting