fixed win calculation function.