Variables scope correction