Thanks for the suggestion. I've rewritten that piece of code (though I've not reused exactly your example because of JSLint).