fixed bug in javascript