documentation and comments added