fix for "write after end" errors
2.3.10