Refactored drawConnectionLines method