adding a v2 that uses dictionaries instead of lists (incomplete)