Refactored Version