refactoring routes_counts_matrix.js