fix potential bug in accessing write position from read method