Add `solveFunctional` to solve this problem more functional way.