Improve verification for custom matcher

This change also avoids run time error(index out of range).