Fix function write