added a calculating average function