Scope issues with DOM targets