improved win detection but still doesn't work