fixed bug causing js functions to crash