more refactoring - issues with scope resolved