Fix scope variable bug