Refactored to make more readable