write function implemented but not tested