fixed bug in demag and added example2