minor reorganization to make code reading easier