add average function to test the reduce