Fix write method