fixed read end check