second version of solution for the problem cost of data