Added matchError function