some improvement of the compare function
some improvement of the compare function
added method for computing average