refactor pin.write. thx jer!