improved section detection, changed minus/plus sign depending on state