Finished PinReader script (untested)