Write function working