added map writing