generalizing diagram implementation