Add safety check against empty strings