fix array is undefined error