added more comments into the code