Moved average to seperate file