Refactored the code for adding comments.