change to matrix manipulation