implemented exact and sample