Refactor rho inside the function