properly handle bufferoverflow