Little fix to avoid entering the foreach if the list is empty