not extendings FilterInputStream but implementing directly to avoid performance overhead