refactor datawriter injection