Fix bug caused by $matched value not being reset to false