trying to get the write function to work