added write hook