tightened up transition code