some changes in the code and more comments