This code is the same as before, but the function is now nested.