now minimized total cost