Fix scope bug