fixed another error in write