uncommented and updated sreekanth code