Bug fixed: main diag wrong computing