Moved weigted_avarage function out of class, avoid multiple messages