Added average method and some private methods