slightly more compact IR read loop, and also added some comments