Function that populate the table, helper functions, ideb average function