add log and matrix output