Refactored for simplicity