Refine the code according to Ram and Anoop's comments