Revert "Fixed variable scope"

This reverts commit af974d68b51d943cfe8d29fc7aeb9af8b209c249.