why not use buffer.position()?