fixed small bug in smartAverage