looks a lot like the mediaElement case, I think the replacement + findAttachment could be done before the if.