fix property of undefined js error