finally working map generation