refactor pin to do less runtime work, and the code actually decreased in size