Fix js crashing