Better create a private class for the cost function.