added check for empty data