figured out some scope issues