readded code deleted by Prathik along with minor changes