updated to allow multiple graphs