You have to assign avg to f after calculating avg.