first version to detect winning state