updated comments and formatting