adding comments and working on structure of js file to make it easier for new developers to contribute.