fix empty and null data cases