end_match function implemented