code and comments added