Fixed some scope issues with on off