starting code generation for write and optimizing read.