simplifying matrix package