improve state machine to be able handle all non-nested content