Fixed undefined js errors