fixed 0 on diagonal matrix bug