As far as I can see your code does what you want, so I repeat ... What are you trying to do that doesn't work (yet!)?