Yeah iopq's answer looks right and Mass & ISF's way is much easier to understand than mine.