add   documentation and fix errors