for robustness, use version-handling code in writePtr between segments