added detection of winner, but algorithm fails