print pid on err
matrix construction fixed