optimize writing in yaml