Remove duplicate code in pin.