refactor the long function dectWin function