Could you pull out into a separate function and use `Map`?