Refine the code according to Anoop's patch.