Lets have a think. This is uglier than John-David's way, but may be the best option