Updated code based on suggestions.