fix scope issues