Complete rewrite using YUI3