more code reorganization