my ($x1,$y1,$x2,$y2) = $self->GetHorizontalCoord($xcoord1,$ycoord1,$xcoord2,$ycoord2,$threshold); print "The horizontal coordinates are $x1,$y1,$x2,$y2 \n"; print "The element1 is $element1 \n"; if ( $element1 =~ m/$regex1/g ) { print "To check for iImage"; my $region = $self->WaitForImageInROI($element1,$x1,$y1,$x2,$y2,$duration); return ($region); } else { print "To check for tText"; my $region = $self->WaitForTextInROI($element1,$x1,$y1,$x2,$y2,$duration); return ($region); }