pass diagram as parameter