Refine the code according to Anoop's comment.