cleaned up digram code