solution to list comprehension problem