Replaces multiple casts with list comprehension