added detecting the winning