additional refactoring to eliminate weak places