begun source sampling code