refactor logic surrounding winning