not exactly sure why this DOM check is still needed, but perhaps the refactoring i mentioned above will help clear things up a bit more.