fix some wierd scope issues