more refactoring - still broken