duplicated code in h5