some fixes in terms of map

Mainly, make a intermediate function to get the keys we want. 
What is your suggestion here for the loc problem ?