Using common code to find the element sounds like the right approach.