Fixing scope problems