Refactored to use global jsPlumb variable