added check to prevent a bug from the original SetMap()