fixed the javascript error when data is empty