added logic to display route through the matrix