Updated text comparison function