implement and use tailUntilMatch method