added check for an empty list of objects after filtering