Improvements on segment logic