added match and sample, along with docs and tests