refactor: extract model_to_matrix