impl write func