Little modification on Borja's function CheckWin