use Buffer.remaining()