fixed sign error in invariant
fixed malicious flag (again)