fix Javascript bug (undefined var)