Added Write function