fixed issue with concat; reduced footprint of transition detection function