Fix extern var bug