Rewrite to use the new DOM