modified code and comments