Converted import_dataset to function
some improvements