moved code to extract information from 'external' datasets to a separate file