Update code based on the review from @chrisndodge