written dataloading code