Simplified based on cobyism suggestion.