Use map instead of hacking path to our need.

might help closing #7034