moved a little code around