set default value to average to avoid compiler warnings
added function for averaging a pointer of longs