added local matrix as one of the return variables