Trying processing of records in write function