tightened up some code