working on fixing segment count inc/dec bug