I think a combination of these two samples should help you to achieve your goal:
Thanks,
BrozTechnologies