Fix bug in match_length