I am following and trying to fully understand a famous and interesting work of Bentolila and Saint-paul (2003). They try to explain movements of the factor's share in terms of a relationship between the labor share ($LS$) and the capital-output ratio ($k$). To summarize as much as possible they start from a general production function with labor-augmenting technological progress and constant returns to scale:
$$Y_{i} = F(K_{i},B_{i}L_{i})=K_{i}f(l_{i}),$$
where $l_{i}=\frac{B_{i}L_{i}}{K_{i}}.$ And show that under the usual microeconomic assumptions of equilibrium (i.e. labor its paid its marginal product), there exists a unique function $g(\cdot)$ such that:
$$S_{Li} = g(k_{i}).$$
where $S_{Li}=\frac{w_iL_i}{p_iY_i}$ the labor share in the industries revenues, with $w_i$ denoting the wage, $p_i$ the product's price and $k_i=\frac{K_i}{Y_i}$ is the capital-output ratio.
Then, at page 6 of the paper, they employ the standard definition of elasticity of substitution to production function above, i.e. $\sigma_{i}=\frac{d(K_i/L_i)}{d(r/w)}\cdot \frac{r/w}{K_i/L_i}$ to obtain the following result:
$$\sigma_{i}=\frac{f'(l_{i})}{l_{i}f''(l_{i})}\left [1-\frac{l_{i}f'(l_{i})}{f(l_{i})} \right ]$$
I am trying to do all the derivations, but I can't find a way to derive this last formula with the same result. Is there someone who could kindly help me and show me the steps?.