some fixes in terms of map

Mainly, make a intermediate function to get the keys we want. 
You're reverting stuff here.