replacing matrix library