fixed cost function.

have to consider rows count, but size returns rows*cols value