fixed generate map function