Refine the code based on Jon's comments.