finish matrix A