building variables to find an average