fix bugs for mapping