Changed the write method