(HDAT) Initial working code