Add cost function based approach.