Swithing to imap from list comprehension.