refactor of diagraph definition