Issue #285 add documentation and fix code