fixing bug in update_datasets() iterations