proof of concept for dataset filtering. Needs testing and tidyup