fix bug when data is undefined