change to list comprehension
use hashmap, works for naive cases