handle internal scope correctly