restoring matrix