refactoring for writer interface  and graph builder