fixed scope issues relating to refactoring