winner determination code