fix the javascript to determine winner