refactored impl