Added condition to ensure the remaining text is not empty