matching logic with string comparison