segmented write code finished, not debugged yet