Ribs evolved for movement first, then co-opted for breathing

When early tetrapods transitioned from water to land the way they breathed air underwent an evolutionary revolution. Fish use muscles in their head to pump water over their gills. The first land animals utilized a similar technique—modern frogs still use their head and throat to force air into their lungs. Then another major transformation in vertebrate evolution took place that shifted breathing from the head to the torso. In reptiles and mammals, the ribs expand to create a space in the chest that draws in breath. But what caused the shift?