Functional version.