Code changes as per Ninad's comments