Refactored based on hlint suggestions.