Updated matrix functions