Corrects variable scope