Bug fix for negative values of x(kk)
Merge pull request #413 from rattoma/master

bug fix mode_chek