modified some comments for better clarity. enclosed code blocks for syntax highlighting