added more  commenting in the code