Add more branch for segment segment checking
Add a global log variable