fixed map generation code