more refactored