minor reorganization of code.