fix the getting length of undefined value