Making text comparison function more readable