updated the isWin function to return result