move variable declaration to more proper scope