updated code with new comments