Addressing int overflow which will cause the stream to jump to begining