adding active sampling code