Compare matrix value before setting
Fix windows build