Refactored based on suggestion.