write post function