scans both strings simultaneously