added functions to extract sets and write datacards