Shawn-2103 fixing bugs in average.py