Refine the code according to Jon and Anoop's comments.