Functional version of part 3