refactor IID metadata code