refractoring bet algorithm
fix error in extra summ