a little refactoring to simplify readFrames

factoring some things out of readFrames to simplify understanding what's going on