minor code reorganization