Use list comprehension instead of foreach/1

Tidy up.