Fixing issue with scoping