short sctipt for averaging