more efficient writing of metadata