finally getting correct result! Fixed small typo, integrateModeMedium was not catching the degenerate mode.