Replaced an unnecessarily long list comprehension with a loop.