Finding the optimal capital structure