Fix scope determination