reorganized some of the code...no substantive changes