script to get the average