I'm not a big fan of having this check inside the map. The condition is known outside of the for, so their should be a clean way to have the check outside the map.