Map over the list, rather than a while loop.