start adapting matrix exp code