solve bugs for average