some changes and comments added