added isWin function. Should be changed