changed matrices to arrays