Bug fix in javascript variable