add method getAverageLength of code