changed from matrices to arrays