Fixed map write function