Fix bug on multiple diagrams