Added a shorter version that does the same thing using map.