Replace temp with inline list comprehension