This is good but I think an example would help (I was still confused thinking about it while reading the code).