adding matrix functions