refactored defactor