fix weird javascript implicit global variable problem