Replaced helper functions with list comprehensions