Fixed accessing .length of undefined data