Updated pattern matching for key migration