fixed EM_demo by adding one more check for LinAlgErrors