more refactoring needed