There's more wrong, but the above is close to your code and works. At least with trunk. Can't test other versions today.